import axios from 'axios';

export function register(){
    var params = {
        name: $('#register-name').val(),
        account: $('#register-account').val(),
        password: $('#register-password').val()
    }

    axios.get('/register', {
        params: params
    })
    .then(function(response){
        var req = response.data;
        switch (req.code) {
            case 200:
                window.location = '/book'
                break;
            case 400:
                $('#register-error').html('该用户已存在');
                $('#register-error').show();
                break;
        }
    })
    .catch(function(error){
        alert('系统出错');
    })
}